package com.woniu.dating.controller;

import com.woniu.common.annotation.LoginDating;
import com.woniu.common.entity.Result;
import com.woniu.dating.dto.DynamicDTO;
import com.woniu.dating.service.IDatingDynamicService;
import com.woniu.dating.vo.DatingLoginVO;
import com.woniu.dating.vo.DynamicVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 玖柒
 * @since 2023-05-20
 */
@RestController
@RequestMapping("/datingDynamic")
@Api(tags = "动态信息")
public class DatingDynamicController {

    @Resource
    private IDatingDynamicService datingDynamicService;


    /**0
     * 按照用户id,查看动态信息
     */
    @ApiOperation("个人动态展示")
    @GetMapping("/person")
    public Result<List<DynamicVO>> getDatingDynamic(@LoginDating DatingLoginVO datingLoginVO) {
        List<DynamicVO> listDynamicVO = datingDynamicService.getDatingDynamic(datingLoginVO);
        return Result.ok(listDynamicVO);
    }

    /**
     * 通过userId,查询别人德动态信息
     */
    @ApiOperation("查询别人动态")
    @GetMapping("/person/userId")
    public Result<List<DynamicVO>> getDatingDynamicPerson(@PathVariable Integer userId) {
        List<DynamicVO> listDynamicVO = datingDynamicService.getDatingDynamicPerson(userId);
        return Result.ok(listDynamicVO);
    }

    /**
     * 删除动态
     */
    @ApiOperation("删除动态")
    @GetMapping("/delete/{dynamicId}")
    public Result deleteDynamic(@PathVariable Integer dynamicId, @LoginDating DatingLoginVO datingLoginVO) {
        datingDynamicService.deleteDynamic(datingLoginVO,dynamicId);
        return Result.ok();
    }

    /**
     * 发布动态
     */
    @ApiOperation("发布动态")
    @PostMapping("/add")
    public Result addDynamic(@LoginDating DatingLoginVO datingLoginVO, @RequestBody DynamicDTO dynamicDTO) {
        datingDynamicService.addDynamic(datingLoginVO,dynamicDTO);
        return Result.ok();
    }

    /**
     * 动态圈
     */
    @ApiOperation("动态圈")
    @GetMapping("/dynamic")
    public Result<List<DynamicVO>> dynamicCircle(@LoginDating DatingLoginVO datingLoginVO) {
        List<DynamicVO> listDynamicVO = datingDynamicService.dynamicCircle(datingLoginVO);
        return Result.ok(listDynamicVO);
    }

}
